package com.ideal.frame.sys.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ideal.frame.entity.AutoModel;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * @Author: jin
 * @CreateTime: 2020-01-12 14:29
 * @Description: 操作日志表
 */
@Table(name = "t_sys_log")
@Entity
@Getter
@Setter
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class SysLog extends AutoModel {
    private String title;
    private String remoteAddr;
    private String requestUri;
    private String method;
    private String params;
    private String userAgent;
    private String exception;
    private Long userId;
    private String loginName;
    private Date beginTime;
    private Date endTime;

    public SysLog(){}

    private SysLog(Builder builder) {
        setId(builder.id);
        setTitle(builder.title);
        setRemoteAddr(builder.remoteAddr);
        setRequestUri(builder.requestUri);
        setMethod(builder.method);
        setParams(builder.params);
        setUserAgent(builder.userAgent);
        setException(builder.exception);
        setLoginName(builder.loginName);
        setBeginTime(builder.beginTime);
        setEndTime(builder.endTime);
    }


    public static final class Builder {
        private Long id;
        private String title;
        private String remoteAddr;
        private String requestUri;
        private String method;
        private String params;
        private String userAgent;
        private String exception;
        private String loginName;
        private Date beginTime;
        private Date endTime;

        public Builder() {
        }

        public Builder id(Long val) {
            id = val;
            return this;
        }

        public Builder title(String val) {
            title = val;
            return this;
        }

        public Builder remoteAddr(String val) {
            remoteAddr = val;
            return this;
        }

        public Builder requestUri(String val) {
            requestUri = val;
            return this;
        }

        public Builder method(String val) {
            method = val;
            return this;
        }

        public Builder params(String val) {
            params = val;
            return this;
        }

        public Builder userAgent(String val) {
            userAgent = val;
            return this;
        }

        public Builder exception(String val) {
            exception = val;
            return this;
        }

        public Builder loginName(String val) {
            loginName = val;
            return this;
        }

        public Builder beginTime(Date val) {
            beginTime = val;
            return this;
        }

        public Builder endTime(Date val) {
            endTime = val;
            return this;
        }

        public SysLog build() {
            return new SysLog(this);
        }
    }
}
